<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        span{
            background-color: black;
            width: 100px;
            height: 100px;
            float: left;
            margin-left: 10px;
            font-weight: 800;
            line-height: 100px;
            text-align: center;
            font-size: 60px;
            color: #fff;
        } 
    </style>
</head>
<body>
    <div>
        <span class="hour">1</span>
        <span class="minute">2</span>
        <span class="second">3</span>
    </div>
</body>
<script>
    let hour = document.querySelector('.hour');
    let minute = document.querySelector('.minute');
    let second = document.querySelector('.second');
    let inputTime = +new Date('2022-8-3 16:00:00');
    countDown()
    setInterval(countDown, 1000);
    function countDown(){
        let nowTime = +new Date(); //当前时间的总毫秒数
        let times = (inputTime-nowTime)/1000;
        let h = parseInt(times/3600%24);
        h = h<10 ? '0'+h : h;
        hour.innerHTML = h;
        let m = parseInt(times/60%60);
        m = m<10 ? '0'+m : m;
        minute.innerHTML = m;
        let s = parseInt(times%60);
        s = s<10 ? '0'+s : s;
        second.innerHTML = s;
    }
</script>
</html>